package com._58city.spark.app.ext.dao;

import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;

import org.springframework.jdbc.core.simple.ParameterizedRowMapper;

import com._58city.spark.app.ext.dto.DispCity;

/**
 * @author lihao 城市字典表，主要是需要一级城市ID和名称
 */
public class DispCityDao extends BaseDao implements ParameterizedRowMapper<DispCity> {

	public List<DispCity> select_all() {
		String sql = String.format("select city_id,city1_id,city1_name,city_name_en from %s", super.tableName);
		List<DispCity> result = this.jdbcTemplate.query(sql, this);
		if (null != result) {
			return result;
		} else {
			return new ArrayList<DispCity>();
		}
	}

	public DispCity mapRow(ResultSet rs, int rowNum) throws SQLException {
		DispCity res = new DispCity();
		res.setCity_id(rs.getLong("city_id"));
		res.setCity1_id(rs.getLong("city1_id"));
		res.setCity1_name(rs.getString("city1_name"));
		res.setCity_name_en(rs.getString("city_name_en"));
		return res;
	}

}
